export default {
  data() {
    return {
      // 计数器数据
      count: 0,
      // 时间相关数据
      createdTime: '',
      lastUpdateTime: '',
    };
  },

  computed: {
    reverseName() {
      return `${this.firstName}${this.lastName}`.split('').reverse().join('');
    }
  },

  // 生命周期钩子
  created() {
    this.createdTime = new Date().toLocaleString();
    console.log('Mixin created hook called');
  },

  mounted() {
    console.log('Mixin mounted hook called');
  },

  // 方法
  methods: {
    increment() {
      this.count++;
      this.updateTime();
    },
    decrement() {
      this.count--;
      this.updateTime();
    },
    updateTime() {
      this.lastUpdateTime = new Date().toLocaleString();
    }
  },

  // watch
  watch: {
    watchValue: {
      handler(newVal) {
        if (newVal) {
          this.watchHistory.push(`${new Date().toLocaleTimeString()}: ${newVal}`);
        }
      }
    }
  }
};